﻿/////////////////////////////////////////////////////////
// Author   : huangzhiming
// Date     : 12/20/2011 9:52:33 AM
// Usage    :
/////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace TM.PowerPointController.Server
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private UIElement _currentPivotPanel;

        private void RecentSelected(object sender, RoutedEventArgs e)
        {
            ShowPivot(pivotRecent);
        }

        private void SettingSelected(object sender, RoutedEventArgs e)
        {
            ShowPivot(pivotSetting);
        }

        private void AboutSelected(object sender, RoutedEventArgs e)
        {
            ShowPivot(pivotAbout);
        }

        private void ShowPivot(UIElement panel)
        {
            panel.Visibility = System.Windows.Visibility.Visible;
            if (_currentPivotPanel != null)
                _currentPivotPanel.Visibility = System.Windows.Visibility.Collapsed;

            _currentPivotPanel = panel;
        }

        # region DropShadow

        private WindowShadow _shadow;

        private void Window_SourceInitialized(object sender, EventArgs e)
        {
            _shadow = new WindowShadow(this);
            pivotHeaders.SelectedIndex = 0;
        }
        #endregion

        #region MetroUI

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Shutdown();
        }

        private void Rectangle_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            // BUG 14: Only call DragMove if the left button (the primary one) is pressed
            if (e.LeftButton == MouseButtonState.Pressed)
                DragMove();
        }

        private void btnMinimize_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = System.Windows.WindowState.Minimized;
        }

         /* private void btnMaximise_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = System.Windows.WindowState.Maximized;
        }

        private void btnRestore_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = System.Windows.WindowState.Normal;
        }

      protected override void OnStateChanged(EventArgs e)
        {
            if (WindowState == System.Windows.WindowState.Maximized)
            {
                btnMaximise.Visibility = System.Windows.Visibility.Collapsed;
                btnRestore.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                btnMaximise.Visibility = System.Windows.Visibility.Visible;
                btnRestore.Visibility = System.Windows.Visibility.Collapsed;
            }

            base.OnStateChanged(e);
        }*/

        #endregion

        private void btnAbout_Click(object sender, RoutedEventArgs e)
        {
            dialogAbout.Show();
        }

    }
}
